<template>
	<view class="content pB50">
		<view class="input-group">
			<view class="input-row border">
				<text class="title">邀请单位：</text>
				<!-- <m-input type="text" clearable v-model="appointmentdetails.dept_name" placeholder="请填写到访位置">{{appointmentdetails.dept_name}}</m-input> -->
				<view class="tab w70" v-bind:class="{ active: isActive }">{{ appointmentdetails.company_name}}</view>
				<view class="w15"></view>
			</view>
			<view class="input-row border">
				<text class="title">邀请部门：</text>
				<!-- <m-input type="text" clearable v-model="appointmentdetails.dept_name" placeholder="请填写到访位置">{{appointmentdetails.dept_name}}</m-input> -->
				<view class="tab w70" v-bind:class="{ active: isActive }" @tap="toggleTab('selector')">
					{{ resultInfodept.result}}</view>
				<view class="w15" @tap="toggleTab('selector')" v-if="showtype!='yq'">
					<span class='f12 col_999'>修改</span>
					<uni-icons type="arrowright" size="20"></uni-icons>
				</view>
				<view class="w15" v-if="showtype=='yq'"></view>
			</view>
			<view class="input-row border">
				<text class="title">邀请人员：</text>
				<!-- <m-input type="text" clearable v-model="appointmentdetails.dept_name" placeholder="请填写到访位置">{{appointmentdetails.dept_name}}</m-input> -->
				<view class="tab w70" v-bind:class="{ active: isActive }">{{ appointmentdetails.uname}}</view>
				<view class="w15"></view>
			</view>
			<view class="input-row border">
				<text class="title">手机号码：</text>
				<!-- <m-input type="text" clearable v-model="appointmentdetails.dept_name" placeholder="请填写到访位置">{{appointmentdetails.dept_name}}</m-input> -->
				<view class="tab w70" v-bind:class="{ active: isActive }">{{ appointmentdetails.mobile}}</view>
				<view class="w15"></view>
			</view>
			<view class="input-row border">
				<text class="title">到访日期：</text>
				<!--  <m-input type="text" @focus="toggleTab('date')" clearable v-model="resultInfo.result" placeholder="请选择到访时间"></m-input> -->
				<view class="tab w70 " v-if="dj == true" v-bind:class="{ active: isActive }" @tap="toggleTab('date')">
					{{ vistertime.date }} <span class="f12 pL5" v-if="vistertime.date != '请选择到访日期'">（{{nowweek}}）</span>
				</view>
				<view class="w15" @tap="toggleTab('date')">
					<span class='f12 col_999'>修改</span>
					<uni-icons type="arrowright" size="20"></uni-icons>
				</view>
			</view>

			<view class="input-row border">
				<text class="title">到访开始：</text>
				<!-- <view class="tab w70 " v-bind:class="{ active: isActive }" @tap="toggleTab('time')">{{ vistertime.time }}</view> -->

				<picker v-if="dj == true" mode="time" class=" w70" :value="time" @change="bindTimeChange">
					<view class="tab" v-bind:class="{ active: isActive }">{{time?time:'请选择到访开始时间'}}</view>
				</picker>

				<view class="w15">
					<span class='f12 col_999'>修改</span>
					<uni-icons type="arrowright" size="20"></uni-icons>
				</view>

			</view>
			<view class="input-row border">
				<text class="title">到访结束：</text>
				<!-- <view class="tab w70 " v-bind:class="{ active: isActive }" @tap="toggleTab('time')">{{ vistertime.time }}</view> -->

				<picker v-if="dj == true" mode="time" class=" w70" :value="timeend" @change="bindTimeChangeend">
					<view class="tab" v-bind:class="{ active: isActive }">{{timeend?timeend:'请选择结束时间'}}</view>
				</picker>

				<view class="w15">
					<span class='f12 col_999'>修改</span>
					<uni-icons type="arrowright" size="20"></uni-icons>
				</view>

			</view>
			<view class="border input-row f14" v-if="showtype == 'yq'">
				<!-- <view style="padding-left: 15px;padding-top: 5px;">到访事由：</view> -->
				<text class="title" style="width: 200rpx;">车牌号码：</text>
				<view class="uni-textarea tab w70">
					<!-- <textarea  @click="inputstate()" auto-height v-model="carnumber" placeholder="车牌号码" /> -->
					<!-- <m-input @click="inputstate"  type="text" class="f14"  clearable v-model="carnumber"  placeholder="请填写车牌号码"></m-input> -->
					<div class="radioall">
						<label class="radio" @click="chooseradio('1')">
							<radio value="r1" :checked="radiostate==='1'" />无
						</label>
						<label class="radio mL10" @click="chooseradio('2')">
							<radio value="r2" :checked="radiostate==='2'" />有
						</label>
						<div class="w50 inline-block vm pL5" v-if="radiostate==='2'">
							<input type="text" class="f14 pL5 fangcarnumbers" v-model="carnumber"
								placeholder="请填写车牌号码" />
							<!-- <m-input  type="text" class="f14"  clearable v-model="carnumber"  placeholder="请填写车牌号码"></m-input> -->
						</div>
					</div>
					<!-- <view class="" v-if='!carnumbershow'>
						无
					</view> -->
				</view>

			</view>

			<view class="input-row border" v-if="showtype!='yq'">
				<!-- <view style="padding-left: 15px;padding-top: 5px;">到访原由：</view> -->
				<text class="title">访客姓名：</text>
				<view class="uni-textarea tab w70" style="">
					<input type="text" class="f14 fangshowyuanyou" v-model="appointmentdetails.visit_name"
						placeholder="请填写访客姓名" />
					<!-- <m-input  type="text" class="f14" clearable  v-model="appointmentdetails.reson"  placeholder="请填写到访原由"></m-input> -->
				</view>
			</view>
			<view class="input-row border">
				<!-- <view style="padding-left: 15px;padding-top: 5px;">到访原由：</view> -->
				<text class="title">到访原由：</text>
				<view class="uni-textarea tab w70" style="">
					<!-- <textarea auto-height v-model="appointmentdetails.reson" placeholder="请填写到访缘由" /> -->

					<input type="text" class="f14 fangshowyuanyou" v-model="appointmentdetails.reson"
						placeholder="请填写到访原由" />
					<!-- <m-input  type="text" class="f14" clearable  v-model="appointmentdetails.reson"  placeholder="请填写到访原由"></m-input> -->
				</view>
			</view>
			<!-- <view class="Approved" v-if="showtype!='yq'">
				<div class="radioall p10 tCenter" >
					<label class="radio" @click="chooseradio2('1')"><radio value="r1"  :checked="radiostate2==='1'" />简易注册</label>
					<label class="radio mL10" @click="chooseradio2('2')"><radio value="r2"  :checked="radiostate2==='2'" />完整注册</label>
										
				</div>
			</view> -->
			<view class="f14 border" v-if="showtype!='yq'">
				<view class="input-row">
					<text class="title" style="width: 200rpx;">注册方式：</text>
					<view class="uni-textarea tab w70">
						<label class="radio" @click="chooseradio2('1')">
							<radio value="r1" :checked="radiostate2==='1'" />简易注册
						</label>
						<label class="radio mL10" @click="chooseradio2('2')">
							<radio value="r2" :checked="radiostate2==='2'" />完整注册
						</label>
					</view>
					<view class="w15"></view>
				</view>
				<view class="w100" style="padding-bottom:10upx ;">
					<div class="f14 pL10 pR10 col_999" v-if="radiostate2==='1'">适合邀请贵宾和熟客来访，仅需访客输入姓名和手机号码</div>
					<div class="f14 pL10 pR10 col_999" v-if="radiostate2==='2'">
						适合业务往来到访，访客上传身份证照片和人脸识别拍照，系统自动进行身份信息智能核对，确保人证相符</div>
				</view>
			</view>
		</view>
		<view class="btn-row w70 mauto"><button type="primary" class="primary "
				@click="demo.submitadds">{{showtype=='yq'?'提交':'提交'}}</button></view>
		<w-picker :visible.sync="date1visible" mode="date" :startYear="showyearin" :endYear="showyearinend"
			:current="false" :value="vistertimedate" fields="day" @confirm="onConfirm($event,'date')" @cancel="onCancel"
			:disabled-after="false" ref="date"></w-picker>

		<w-picker :visible.sync="date2visible" mode="time" :current="false" :second="true"
			@confirm="onConfirm($event,'time')" @cancel="onCancel" ref="time"></w-picker>

		<w-picker :visible.sync="date3visible" mode="selector" value="" default-type="name"
			:default-props="defaultProps" :options="deptlist" @confirm="onConfirm($event,'selector')" @cancel="onCancel"
			ref="selector"></w-picker>
		<!-- 		<w-picker mode="date" :startYear="showyearin" :endYear="showyearinend" :current="false" @confirm="onConfirm" :disabledAfter="false" ref="date" themeColor="#f00"></w-picker>

		<w-picker mode="time" :current="false" :hasSecond="false" @confirm="onConfirmtime" ref="time" step="1"></w-picker> -->
		<!-- 底部导航 -->
		<footernav pagePath='user'></footernav>
		<!-- 加载动画 -->
		<loading v-if="!isloading()"></loading>
	</view>
</template>
<script module="demo" lang="renderjs">
	export default {
		methods: {

			submitadds: function(event, ownerInstance) {
				// document.getElementsByTagName("input")[0].value

				if (document.getElementsByClassName("fangshowyuanyou").length > 0) {
					var vale2 = document.getElementsByClassName("fangshowyuanyou")[0].childNodes[0].childNodes[1]
						._value;
					var newvale2 = vale2
				} else {
					var newvale2 = '';
				}

				if (document.getElementsByClassName("fangcarnumbers").length > 0) {
					var vale = document.getElementsByClassName("fangcarnumbers")[0].childNodes[0].childNodes[1]._value;
					var newvale = vale
				} else {
					var newvale = '';
				}

				let temp = {
					vale: newvale,
					vale2: newvale2,
				};
				ownerInstance.callMethod('register', temp);
			},
		},
	}
</script>
<script>
	import mInput from '@/components/m-input.vue';
	import wPicker from '@/components/w-picker/w-picker.vue';
	import request from '@/common/vmeitime-http/requstx.js';
	import {
		appointmentinfo,
		appointmentedit
	} from '@/common/api/appointment.js';
	import {
		showgetlist
	} from '@/common/api/department.js'
	let _this = null;
	export default {
		components: {
			mInput,
			wPicker
		},
		data() {
			return {
				radiostate: '',

				page: 1,
				pagesize: 9999,
				date1visible: false,
				date2visible: false,
				date3visible: false,
				defaultProps: {
					label: "name",
					value: "id"
				},
				deptlist: [],
				deptid: '',
				carnumber: '',
				appointmentid: 0,
				appointmentdata: [],
				appointmentdetails: [],
				time: "",
				timeend: '',
				vistertime: {
					date: '请选择到访日期',
					time: '请选择到访时间',
					timeend: '请选择到访时间'
				},
				account: '',
				password: '',
				address: '',
				yuanyou: '',
				beizhu: '',
				showtype: '',
				showyearin: "2020",
				showyearinend: "2030",
				vistertimedate: '',
				isActive: true,
				clickstate: true,
				resultInfo: {
					result: '请选择到访日期',
				},
				resultInfotime: {
					result: '请选择到访时间',
					resultend: '请选择到访时间',
				},
				resultInfodept: {
					result: '请选择到访部门'
				},
				weeks: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
				nowweek: '',
				carnumbershow: '',
				dj: true,
				radiostate2: '',
			};
		},
		onLoad(options) {
			console.log(options)
			// if(options.appointment){this.appointmentid = options.appointment.id}
			try {
				this.appointmentdata = JSON.parse(decodeURIComponent(options.detailDate));
				console.log(this.appointmentdata);
			} catch (error) {
				this.appointmentdata = JSON.parse(options.detailDate);
				console.log(this.appointmentdata);
			}
			if (this.appointmentdata.radiostate && this.appointmentdata.radiostate == '2') {
				this.carnumbershow = 'YES';
				this.carnumber = this.appointmentdata.carnumber
				this.radiostate = '2'
			} else {
				this.radiostate = '1'
			}
			if (this.appointmentdata.is_completeperson && this.appointmentdata.is_completeperson == '2') {
				this.radiostate2 = this.appointmentdata.is_completeperson
				this.radiostate2 = '2'
			} else {
				this.radiostate2 = '1'
			}

			this.appointmentid = this.appointmentdata.id;

			if (this.appointmentdata.type) {
				this.showtype = this.appointmentdata.type
			}
			appointmentinfo({
				id: this.appointmentid
			}).then(res => {
				if (res.data.code == 200) {
					this.appointmentdetails = res.data.data
					var vistertime = this.appointmentdetails.visittime.split(' ')
					var vistertimeend = this.appointmentdetails.endvisittime.split(' ')
					// this.radiostate2 = this.appointmentdetails.is_completeperson;
					// console.log('注册方式'+this.radiostate2)
					console.log(vistertime[1])
					this.vistertime.date = vistertime[0]
					this.vistertime.time = vistertime[1]
					this.vistertime.timeend = vistertimeend[1]

					this.timeend = vistertimeend[1]
					this.time = vistertime[1]
					this.vistertimedate = vistertime[0];
					var dateTime = new Date(this.vistertime.date);
					var day = dateTime.getDay();
					this.nowweek = this.weeks[day];
					// this.carnumber=this.appointmentdetails.appointment_details.carnumber
					// if(this.appointmentdetails.appointment_details.carnumber){
					// 	this.radiostate='2'
					// }
					this.resultInfodept.result = res.data.data.dept_name
					this.address = res.data.data.dept_name
					this.deptid = res.data.data.deptid
					// this.$forceUpdate()
				}

			})
		},
		onShow() {
			var thisdata = new Date();
			var thisyear = thisdata.getFullYear();
			this.showyearin = thisyear; //获取当时时间年
			this.showyearinend = thisyear + 5;
		},

		methods: {
			chooseradio(type) {
				this.radiostate = '';
				this.radiostate = type;
				console.log(this.radiostate)
			},
			chooseradio2(type) {
				this.radiostate2 = '';
				this.radiostate2 = type;
			},

			bindTimeChange: function(e) {
				var times = e.detail.value
				var timearr = times.split(':');
				if (Number(timearr[0]) <= 8 && Number(timearr[1]) == 0) {
					uni.showToast({
						icon: 'none',
						title: '请在当天上午8：00之后进行预约'
					});
					return;
				}
				if (Number(timearr[0]) >= 18 && Number(timearr[1]) > 0) {
					uni.showToast({
						icon: 'none',
						title: '请在当天下午18：00之前进行预约'
					});
					return;
				}
				// if(this.timeend){
				// 	var timesthis=Number(times.replace(':',''));
				// 	var timesold=Number(this.timeend.replace(':',''));	

				// 	if(timesthis>=timesold){
				// 		uni.showToast({
				// 			icon: 'none',
				// 			title: '预约开始不能高于预约结束'
				// 		});
				// 		return;
				// 	}
				// }
				this.time = e.detail.value
				this.resultInfotime.result = e.detail.value;
				this.vistertime.time = e.detail.value



				// var newhour=Number(timearr[0])+1+':'+timearr[1];
				if ((Number(timearr[0]) + 1) >= 10) {
					var hour2 = Number(timearr[0]) + 1;
				} else {
					var hour2 = '0' + (Number(timearr[0]) + 1);
				}
				var newhour = hour2 + ':' + timearr[1];
				console.log(newhour)
				this.timeend = newhour
				this.resultInfotime.resultend = newhour
				this.vistertime.resultend = newhour
				this.vistertime.timeend = newhour


			},
			bindTimeChangeend: function(e) {
				var times = e.detail.value
				var timearr = times.split(':');
				if (Number(timearr[0]) <= 8 && Number(timearr[1]) == 0) {
					uni.showToast({
						icon: 'none',
						title: '请在当天上午8：00之后进行预约'
					});
					return;
				}
				if (Number(timearr[0]) >= 19 && Number(timearr[1]) > 0) {
					uni.showToast({
						icon: 'none',
						title: '请在当天下午19：00之前进行预约'
					});
					return;
				}
				if (this.time) {
					var timesthis = Number(times.replace(':', ''));
					var timesold = Number(this.time.replace(':', ''));

					if (timesthis <= timesold) {
						uni.showToast({
							icon: 'none',
							title: '预约结束不能低于预约开始'
						});
						return;
					}
				}
				this.timeend = e.detail.value
				this.resultInfotime.resultend = e.detail.value;
				this.vistertime.timeend = e.detail.value
				if (!this.time) {

					// var newhour=Number(timearr[0])-1+':'+timearr[1];

					if ((Number(timearr[0]) - 1) >= 10) {
						var hour2 = Number(timearr[0]) - 1;
					} else {
						var hour2 = '0' + (Number(timearr[0]) - 1);
					}
					var newhour = hour2 + ':' + timearr[1];


					var newhour = hour2 + ':' + timearr[1];
					console.log(newhour)
					this.time = newhour
					this.resultInfotime.result = newhour;
					this.vistertime.time = newhour
				}

			},
			/*获取部门*/
			getdeptlist() {
				showgetlist({
					companyid: this.appointmentdata.companyid,
					page: this.page,
					pagesize: this.pagesize,
					type: 'link',
				}).then(res => {

					this.deptlist = res.data.data

				})
				console.log(this.deptlist)
			},
			toggleTab(str) {
				let that = this;
				this.visittime = this.resultInfo.result + " " + this.resultInfotime.result;

				console.log(this.visittime);

				var datex = new Date(this.visittime);
				var time1 = datex.getTime();
				console.log(time1);

				var datexx = new Date();
				var time2 = datexx.getTime();

				if (time1 <= time2) {
					that.dj = true
					uni.showToast({
						icon: 'none',
						title: '请选择正确的时间'
					});
					return;
				}

				if (str == 'selector') {
					if (this.showtype == 'yq') {
						return;
					}
					this.getdeptlist()
				}
				this.$refs[str].show();
			},
			onCancel(res, val) {
				/*code*/
			},
			onConfirm(res, val) {
				console.log(res);
				//如果页面需要调用多个mode类型，可以根据mode处理结果渲染到哪里;
				switch (val) {
					case 'date':
						this.resultInfo.result = res.value;
						this.vistertime.date = res.value;
						var dateTime = new Date(res.value);
						var day = dateTime.getDay();
						this.nowweek = this.weeks[day];

						break;
					case 'time':
						this.resultInfotime.result = res.value
						this.vistertime.time = res.value
						break;
					case 'selector':
						if (res.result) {
							this.resultInfodept.result = res.result
							this.address = res.result
							this.deptid = res.value
						}
						break;
				}
				// this.resultInfo = { ...val };
				// this.isActive = false;
			},
			// onConfirmtime(val) {
			// 	console.log(val);
			// 	//如果页面需要调用多个mode类型，可以根据mode处理结果渲染到哪里;
			// 	switch (this.mode) {
			// 		case 'time':
			// 			break;
			// 	}
			// 	this.resultInfotime = { ...val };
			// 	this.isActive = false;
			// },

			register(item) {
				let that = this;
				that.isActive =false;
				this.carnumber = item.vale;
				this.appointmentdetails.remark = item.vale2;
				this.visittime = this.resultInfo.result + " " + this.resultInfotime.result;

				console.log(this.visittime);

				var datex = new Date(this.visittime);
				var time1 = datex.getTime();
				console.log(time1);

				var datexx = new Date();
				var time2 = datexx.getTime();
				console.log("time check ")
				console.log(time1)

				console.log(time2);

				if (time1 <= time2) {
					that.dj = true
					that.isActive =true;
					uni.showToast({
						icon: 'none',
						title: '请选择正确的时间'
					});
					return;
				}

				if (this.radiostate == '') {
					that.isActive =true;
					this.dj = true;
					uni.showToast({
						icon: 'none',
						title: '请填写车牌号码'
					});
					return;
				}
				if (this.radiostate == '2' && this.carnumber == '') {
					that.isActive =true;
					this.dj = true;
					uni.showToast({
						icon: 'none',
						title: '请填写车牌号码'
					});
					return;
				}

				if (this.radiostate == '2' && this.carnumber.length < 7 || this.radiostate == '2' && this.carnumber
					.length > 8) {
						that.isActive =true;
					this.dj = true;
					uni.showToast({
						icon: 'none',
						title: '请填写正确的车牌号码'
					});
					return;
				}


				if (this.appointmentdetails.remark.length == 0) {
					this.dj = true;
					that.isActive =true;
					uni.showToast({
						icon: 'none',
						title: '请填写到访原由'
					});
					return;
				}
				// if (this.appointmentdetails.remark.length >12) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '您填写的原由超出12个字，请处理'
				// 	});
				// 	return;
				// }
				if (this.clickstate) {
					this.clickstate = false;
					setTimeout(() => {
						this.clickstate = true;
					}, 2000)



					let details = {
						id: this.appointmentid,
						visittime: this.vistertime.date + " " + this.vistertime.time,
						visittime2: this.vistertime.date + " " + this.vistertime.timeend,
						address: this.appointmentdetails.dept_name,
						reson: this.appointmentdetails.reson,
						remark: this.appointmentdetails.remark,
						vis_name: this.appointmentdetails.visit_name,
						"is_cperson": this.appointmentdetails.is_person_verify
					}
					uni.showLoading({
						title: '正在进行相关操作...'
					});
					appointmentedit({
						id: this.appointmentid,
						visittime: this.vistertime.date + " " + this.vistertime.time,
						visittime2: this.vistertime.date + " " + this.vistertime.timeend,
						address: this.appointmentdetails.dept_name,
						reson: this.appointmentdetails.reson,
						deptid: this.deptid,
						remark: this.appointmentdetails.remark,
						url: this.weixinhttpurl + '/#/pages/yaoqing/xiangqing?detailDate' + encodeURIComponent(JSON
							.stringify(details)),
						carnumber: this.carnumber,
						"is_cperson": this.radiostate2
					}).then(res => {
						uni.hideLoading();
						if (res.data.code == 200) {
							if (this.showtype == 'yq') {
								
								uni.showModal({
									title: '',
									content: '您已修改邀请函信息\n请如约而至\n',
									showCancel: false,
									confirmText: "确定",
									success: function(res) {
										if (res.confirm) {
											console.log('用户点击确定');
											// uni.reLaunch({
											// 	url: "/pages/myyuyue/myyuyue?type=2"
											// });	
											let details = {
												companyid: that.appointmentdetails.companyid,
												appointmentid: that.appointmentid,
												type: 'yq'
											}
											uni.reLaunch({
												url: "/pages/subject/problem?details=" +
													encodeURIComponent(JSON.stringify(details))
											});
										} else if (res.cancel) {
											console.log('用户点击取消');
										}
									}
								});
							} else {
								let that = this;
								uni.showModal({
									title: '',
									content: '修改成功',
									showCancel: false,
									confirmText: "确定",
									success: function(res) {
										if (res.confirm) {
											console.log('用户点击确定');
											that.backrefresh('123');
											let details = {
												companyid: that.appointmentdetails.companyid,
												appointmentid: that.appointmentid,
												type: 'yq'
											}
											uni.reLaunch({
												url: "/pages/subject/problem?details=" +
													encodeURIComponent(JSON.stringify(details))
											});
										} else if (res.cancel) {
											console.log('用户点击取消');
										}
									}
								});

							}
							// uni.reLaunch({
							// 	url:'/pages/shouquan/successful'
							// });
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 2000
							});
						}
					})

					return
					/**
					 * 客户端对账号信息进行一些必要的校验。
					 * 实际开发中，根据业务需要进行处理，这里仅做示例。
					 */
					// uni.navigateTo({
					// 	url: '/pages/yaoqing/xiangqing'
					// });
					// return
					if (this.resultInfo.result == '请选择到访日期') {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请选择到访日期'
						});
						return;
					}
					if (this.resultInfotime.result == '请选择到访时间') {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请选择到访时间'
						});
						return;
					}

					if (this.address.length == 0) {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请填写到访地址'
						});
						return;
					}
					if (this.yuanyou.length == 0) {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请填写到访缘由'
						});
						return;
					}
					if (this.beizhu.length == 0) {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请填写备注'
						});
						return;
					}
					if (this.radiostate == '') {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请选择到车牌号码类型'
						});
						return;
					}
					if (this.radiostate == '2' && this.carnumber == '') {
						that.isActive =true;
						this.dj = true
						uni.showToast({
							icon: 'none',
							title: '请填写车牌号码'
						});
						return;
					}

					const data = {
						account: this.account,
						password: this.password,
						email: this.email
					};
					this.visittime = this.resultInfo.result + " " + this.resultInfotime.result;

					console.log(this.visittime);

					var datex = new Date(this.resultInfo.result);
					var time1 = datex.getTime();
					console.log(time1);

					var datexx = new Date(this.resultInfo.result);
					var time2 = datexx.getTime();
					console.log(time2);

					request({
						url: 'appointment/add',
						method: 'POST',
						data: {
							visittime: this.visittime,
							address: this.address,
							reson: this.yuanyou,
							deptid: this.deptid,
							remark: this.beizhu
						},
						success: res => {
							// uni.showToast({
							// 	title: res.data.message,
							// 	icon: 'none',
							// 	duration: 2000
							// });

							if (res.data.message == 'token已过期') {
								uni.showToast({
									title: res.data.message,
									icon: 'none',
									duration: 2000
								});
								uni.switchTab({
									url: '/pages/main/main'
								});
							} else if (res.data.message == 'token不存在') {
								uni.showToast({
									title: res.data.message,
									icon: 'none',
									duration: 2000
								});
								uni.switchTab({
									url: '/pages/main/main'
								});
							} else if (res.data.message == '用户不存在') {
								uni.showToast({
									title: res.data.message,
									icon: 'none',
									duration: 2000
								});
								uni.switchTab({
									url: '/pages/main/main'
								});
							} else if (res.data.code == 200) {
								uni.showToast({
									title: res.data.message,
									icon: 'none',
									duration: 2000
								});
								let detail = {
									id: res.data.appointmentid
								};
								uni.navigateTo({
									url: '/pages/yaoqing/xiangqing?detailDate=' + encodeURIComponent(
										JSON.stringify(detail))
								});

								this.resultInfo.result = '请选择到访日期';
								this.resultInfotime.result = '请选择到访时间';

								this.address = '';
								this.yuanyou = '';
								this.beizhu = '';
							} else {
								uni.showToast({
									title: res.data.message,
									icon: 'none',
									duration: 2000
								});
							}
						}
					});

					// uni.showToast({
					//     title: '注册成功'
					// });
					// uni.navigateBack({
					//     delta: 1
					// });
				}
			}
		}
	};
</script>

<style>
	.input-row {
		align-items: center;
	}

	.uni-input-placeholder {
		font-size: 14px;
	}

	.tab {
		line-height: 39px;
	}

	.content {
		display: flex;
		flex: 1;
		flex-direction: column;
		background-color: #efeff4;
	}

	.active {
		color: #747272;
	}

	.uni-textarea {
		padding-left: 0;
		width: 90%;
		margin: 5px auto;

	}

	.uni-textarea.on {
		border: 1px solid #CCCCCC
	}
</style>
